<?php
	session_start();
	require("../config.php");
  	require_once($CONF['root.dir']."database.php");
	require_once($CONF['root.dir']."Modules/tabelClass.php");
	
	$kolomCari=$_GET["kolomCari"];
	$tipeCari=$_GET["tipeCari"];
	$dataCari=$_GET["dataCari"];
	
	if ($_GET['i'] == ""){
		$index = 1;
	}else{
		$index = $_GET['i'];
	}

	if ($_GET["aksi"] == "hapusData"){
		$idHapus = $_GET["idHapus"];
		$idArray = explode(";",$idHapus);
		for ($counter=0;$counter<(count($idArray)-1);$counter++){
			$SQL = "DELETE FROM tbltes WHERE id_test = '".$idArray[$counter]."'";
			$conn->connect();
			$exec = $conn->execute($SQL);
			$conn->disconnect();
		}		
	}
	
	$tabelClass = new tabelClass();
	$tabelClass->connection = $conn;
	$tabelClass->widthno='3%';
	
	$arrayHeader = array("ID Pelamar","Nama","Tempat/Tgl Lahir","Status","Hasil Test");
	$arrayAlign = array("","","","","");
	$arrayWidth = array("10%","15%","10%","10%","10%");
	
	if($_SESSION['AR_Priv']=="A"){
	$SQL="SELECT id_pelamar, nama, CONCAT(tmp_lahir,', ',DATE_FORMAT(tgl_lahir,'%d-%m-%Y'))lahir,  
		  if(STATUS='0','Belum Diperiksa','Sudah Diperiksa'),hasil_test,id_test,file FROM tbltes ";
	}else{
	$SQL="SELECT id_pelamar, nama, CONCAT(tmp_lahir,', ',DATE_FORMAT(tgl_lahir,'%d-%m-%Y'))lahir,  
		  if(STATUS='0','Belum Diperiksa','Sudah Diperiksa'),hasil_test,id_test,file FROM tbltes 
		  where id_pelamar='".$_SESSION['AR_ID_PELAMAR']."'";	
	}
	
	if($kolomCari!=""){
		$SQL.=" WHERE ".$kolomCari." LIKE '%".trim(strtoupper($dataCari))."%'";
	}
	
	$tabelClass->sql = $SQL;
	$tabelClass->index = $index;
	$tabelClass->dataPerPage = 10;
	$tabelClass->aksiAjax = "Modules/getHasilTes2.php?";
	$tabelClass->FormName = "FrmTbltes";
	$tabelClass->divAjax = "divtes";
	$tabelClass->showChkPanel = true;
	$tabelClass->indexEdit = "5";
	$tabelClass->indexhide = "5;6";
	$tabelClass->showIcon = true;
	
	if($_SESSION['AR_Priv']=="A"){
	$tabelClass->action=true;
	//$arrayIcon[] = array("1","", "ui-icon-newwin", "New", "ShowPopUp('SubModules/getFrmtes.php','',550,450)", "1");
	$arrayIcon[] = array("1","", "ui-icon-wrench", "Periksa", "Periksa('SubModules/getFrmtes.php','FrmTbltes','divtes',550,450)", "1");
	$arrayIcon[] = array("1","", "ui-icon-trash", "Hapus", "Delete('Modules/getHasilTes2.php?','FrmTbltes','divtes')", "1");
	}
	
	$tabelClass->arrayIcon = $arrayIcon;
	$tabelClass->field = $arrayHeader;
	$tabelClass->alignKolom = $arrayAlign;
	$tabelClass->widthKolom = $arrayWidth;
	$tabelClass->border = "0";
	$tabelClass->cellpadding = "1";
	$tabelClass->width = "100%";	
	$content .= $tabelClass->drawTabel();
	echo $content;

?>